//
//  BKXXSQCSHeader.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/25.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "BKXXSQCSHeader.h"

@implementation BKXXSQCSHeader


- (instancetype)initWithFrame:(CGRect)frame andArray:(NSArray *)array{
    if ([super initWithFrame:frame]) {
        _dataArray = array;
        [self initSubView];
    }
    return self;
}
- (void)initSubView{
    CGFloat W = self.frame.size.width/_dataArray.count;
    CGFloat X = W-15;
    for (int i = 0; i<_dataArray.count; i++){
        UILabel *label = [[UILabel alloc] init];
        if (i<_dataArray.count-1) {
            label.frame = CGRectMake(X*i,0,X,44);
        }else if (i == _dataArray.count-1){
            label.frame = CGRectMake(X*i,0,X+30,44);
        }
        label.numberOfLines = 0;
        label.textAlignment = 1;
        label.text = _dataArray[i];
        label.tag = 30+i;
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = [UIColor darkGrayColor];
        [self addSubview:label];
    }

}
- (void)relodView{
    CGFloat W = self.frame.size.width/_dataArray.count;
    CGFloat X = W-15;
    for (int i = 0; i<_dataArray.count; i++){
        UILabel *label = (UILabel *)[self viewWithTag:30+i];
        if (i<_dataArray.count-1) {
            label.frame = CGRectMake(X*i,0,X,44);
        }else if (i == _dataArray.count-1){
            label.frame = CGRectMake(X*i,0,X+30,44);
        }
        label.text = _dataArray[i];
    }
}
@end
